package com.example.analysis.controller;

import com.example.analysis.entity.Quest;
import com.example.analysis.exception.BusinessException;
import com.example.analysis.service.EvaluationStudentService;
import com.example.analysis.utils.Response;
import com.example.analysis.vo.ReliabilityVO;
import com.example.analysis.vo.ResultVO;
import com.example.analysis.vo.ValidityVO;
import com.example.analysis.vo.WeightVO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/evaluation_analysis")
public class EvaluationAnalysisController {
    @Resource
    private EvaluationStudentService evaluationStudentService;

    @GetMapping("/reliability")
    public Response<List<ReliabilityVO>> reliability(String type, String courseId, String teacherId) {
        List<ReliabilityVO> reliabilityVOList = evaluationStudentService.reliabilityAnalysis(type, courseId, teacherId);
        return new Response<>(true, "成功", reliabilityVOList, 20000);
    }

    @GetMapping("/validity")
    public Response<ValidityVO> validity(String type, int factorNum, double delta) throws BusinessException {
        ValidityVO validityVO = evaluationStudentService.validityAnalysis(type, factorNum, delta);
        return new Response<>(true, "成功", validityVO, 20000);
    }

    @GetMapping("/item_analysis")
    public Response<List<ResultVO>> item(String type, double quantile, double delta) {
        List<ResultVO> resultVOList = evaluationStudentService.itemAnalysis(type, quantile, delta);
        return new Response<>(true, "成功", resultVOList, 20000);
    }

    @GetMapping("/quest")
    public Response<List<Quest>> getQuest(String type) {
        List<Quest> quest = evaluationStudentService.getQuest(type);
        return new Response<>(true, "成功", quest, 20000);
    }

    @PostMapping("/weight")
    public Response<List<WeightVO>> weight(String type, double delta, @RequestBody List<String> processType) {
        List<WeightVO> weightVOList = evaluationStudentService.entropyWeight(type, processType, delta);
        return new Response<>(true, "成功", weightVOList, 20000);
    }
}
